home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4176 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.lpr.carel.fi!usenet
  2. From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: a pointer problem
  5. Date: Fri, 02 Feb 1996 14:59:35 +0200
  6. Organization: Carelcomp Forest
  7. Message-ID: <31120AB7.1C44@cmt.lpr.mail.carel.fi>
  8. References: <4errk0$4c3@srvr1.engin.umich.edu>
  9. NNTP-Posting-Host: renoir.cclahti.carel.fi
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b6a (WinNT; I)
  14.  
  15. Chih-Jen Lin wrote:
  16. > Hi,
  17. > This is an old problem of C. I remember a pointer may point
  18. > to any one address when it's declaired. Is there any way to
  19. > avoid this problem in ANSI C ? Or how can I let a variable be
  20. > NULL while it's declaired ?
  21. > Thanks in advance.
  22. > Chih-Jen Lin
  23.  
  24. You'll have to explicitly initialize the pointer, ANSI C (or any other standard) 
  25. doesn't do it for you. However, most compilers tend to initialize variables (also 
  26. pointers) declared outside of any function scope (or 'static' variables inside 
  27. functions) to zero/NULL, but I wouldn't count on it.
  28.  
  29. Later,
  30.  AriL
  31. -- 
  32. All my opinions are mine and mine alone.
  33.